/*
 */

package labeledbox;

import java.awt.Color;
import java.awt.Graphics;

/**
 */
public class RectShape implements Shape {
  
  // Use this object to DELEGATE most things to (currently using all its properties and methods)
  // Use this AbstractShape for properties of this obj
  AbstractShape abShape = new AbstractShape(); 

  
  // Constructor
  public RectShape() {

  } // end constructor

  
  ////////////////////////////////////////////
  //// METHODS REQUIRED BY THE INTERFACE /////
  
  public void draw(Graphics g) {

    Graphics myG = g.create();
    // FILL RECTANGLE
    if(abShape.getFilled()) {
      Color colorHandle = myG.getColor();

      myG.setColor(abShape.getFillColor());
      myG.fillRect(abShape.getLeft(), abShape.getTop(), abShape.getWidth(), abShape.getHeight());

      myG.setColor(colorHandle);
    }
    // DRAW (BORDER) RECTANGLE
    if(abShape.getBorder()) {
      Color colorHandle = myG.getColor();

      myG.setColor(abShape.getLineColor());
      myG.drawRect(abShape.getLeft(), abShape.getTop(), abShape.getWidth(), abShape.getHeight());

      myG.setColor(colorHandle);
    }

    myG.dispose();
  } //// end draw() ///

  //  Returns TRUE if the shape contains the point and FALSE otherwise.
  //  The shape's BOUNDING BOX determines whether or not the shape contains the point.
  public boolean contains(int x, int y) {
    if(abShape.contains(x, y)) return true;
    else                       return false;
  }

  public int getLeft() {
    return abShape.getLeft();
  }

  public int getTop() {
    return abShape.getTop();
  }

  public int getWidth() {
    return abShape.getWidth();
  }

  public int getHeight() {
    return abShape.getHeight();
  }
  
  ///// end methods required by the interface ////
  ////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////
  //// Additional methods of AbstractShape that this obj wishes to offer /////

  public boolean getBorder() {
    return abShape.getBorder();
  }

  public void setBorder(boolean border) {
    abShape.setBorder(border);
  }

  public Color getFillColor() {
    return abShape.getFillColor();
  }

  public void setFillColor(Color fillColor) {
    abShape.setFillColor(fillColor);
  }

  // returns the whether or not the shape's filled property is true
  public boolean getFilled() {
    return abShape.getFilled();
  }

  public void setFilled(boolean filled) {
    abShape.setFilled(filled);
  }
  // (height getter defined above)
  public void setHeight(int height) {
    abShape.setHeight(height);
  }
  // (getLeft defined above)
  public void setLeft(int left) {
    abShape.setLeft(left);
  }
  // returns the boundary color of the shape
  public Color getLineColor() {
    return abShape.getLineColor();
  }

  public void setLineColor(Color lineColor) {
    abShape.setLineColor(lineColor);
  }
  // (getTop defined above)
  public void setTop(int top) {
    abShape.setTop(top);
  }
  // (getWidth already defined above)
  public void setWidth(int width) {
    abShape.setWidth(width);
  }

} //////////////////// end class RectShape /////////////////////////////
